Skip to main content

Pataa Set delivery location SDK Implementation Guide

Install SDK

To use the Pataa Autofill iOS SDK, you have two options.

Follow the steps for a Cocoapods install:

In your project root directory run this command on terminal

pod init

then open open podfile and past this in your project podfile

pod 'Address-Autofill-iOS'

then save and run this command on terminal

pod install'

Follow the steps below for a manual install:

  1. Download and unzip the PataaAutoFillSDK

  2. Drag the PataaAutoFillSDK.xcframework inside your project under the main project file.

  3. Embed the framework.

  4. Select your project.xcodeproj file.

  5. Under General, add the PataaAutoFillSDK framework in the Frameworks, Libraries & Embedded Content section.

Manual Install

Integration Steps for Objective-C

Follow the steps below for Objective-C:

  1. Import PataaAutoFillSDK.h to your ViewController.h file.

  2. Import PataaAutoFillSDK.h into every class where you plan to use this SDK.

Manual Install

#import <PataaAutoFillSDK/PataaAutoFillSDK.h>
  1. Create a UIView on your UIViewController on the storyboard/xib & assign PataaAddAddressView class & create an IBOutlet of that UIView on your ViewController class. Please set the height of UIView 70 for better visibility

Manual Install

  1. Initialize SDK with your key & app prefix(Team ID) in ViewDidLoad() method.

Manual Install

[objectName initializeSDKWithKey:@"YOUR_API_KEY" withAppPrefix:@"APP_PREFIX"];

Manual Install

Get Pataa Details

Follow the steps below for Objective-C:

To get the details of entered pataa code. Please assign the PataaAddAddressDelegate to your view controller & implement PataaAddAddressDelegate in your ViewController.h file

Manual Install

[objecName setDelegate:self];

After that please implement the delegate methods in your view controller inside a ViewController.m file.

Manual Install


- (void)didReceivedAddPataaDetails:(nullable PAPataaDetail *)pataaDetails withError:(nullable NSError *)error {
}


- (void)didReceivedAddressDetails:(nullable AddressDetails *)addressDetails {
}

In PAPataaDetails, You will get all the details of your pataa & user. To get the pataa details please use the following code:

- (void)didReceivedAddPataaDetails:(nullable PAPataaDetail *)pataaDetails withError:(nullable NSError *)error {
NSLog(@"%@", addressDetails.address1)
NSLog(@"%@", addressDetails.address2)
NSLog(@"%@", addressDetails.address3)
NSLog(@"%@", addressDetails.address4)
NSLog(@"%@", addressDetails.cityName)
NSLog(@"%@", addressDetails.stateName)
NSLog(@"%@", addressDetails.countryName)
NSLog(@"%@", addressDetails.latitude)
NSLog(@"%@", addressDetails.longitude)
}

To get the user details please use the following code:

- (void)didReceivedAddPataaDetails:(nullable PAPataaDetail *)pataaDetails withError:(nullable NSError *)error {
NSLog(@"%@", pataaDetails.user.mobile)
NSLog(@"%@", pataaDetails.user.countryCode)
NSLog(@"%@", pataaDetails.user.firstName)
NSLog(@"%@", pataaDetails.user.lastName)
}

If the user didn’t allow location permission & try to create a pataa then you will get all details in this delegate method.

- (void)didReceivedAddPataaDetails:(nullable PAPataaDetail *)pataaDetails withError:(nullable NSError *)error {
NSLog(@"%@", addressDetails.address1)
NSLog(@"%@", addressDetails.address2)
NSLog(@"%@", addressDetails.address3)
NSLog(@"%@", addressDetails.address4)
NSLog(@"%@", addressDetails.cityName)
NSLog(@"%@", addressDetails.stateName)
NSLog(@"%@", addressDetails.countryName)
NSLog(@"%@", addressDetails.latitude)
NSLog(@"%@", addressDetails.longitude)
}

Follow the steps below for Swift:

To get the details of entered pataa code. Please assign the PataaAddAddressDelegate to your view controller.

objectName.delegate = self

Manual Install

After that please implement the delegate methods in your view controller inside a UIViewController or using an extension.

Manual Install

extension ViewController: PataaAddAddressDelegate {
func didReceivedAddPataaDetails(_ pataaDetails: PAPataaDetail?, withError error: Error?) {
}

func didReceivedAddressDetails(_ addressDetails: AddressDetails?) {
}
}

In PAPataaDetails, You will get all the details of your pataa & user. To get the pataa details please use the following code:

extension ViewController: PataaAddAddressDelegate {
func didReceivedAddPataaDetails(_ pataaDetails: PAPataaDetail?, withError error: Error?) {
if let pataaDetails = pataaDetails, let pataa = pataaDetails.pataa {
print(pataa.pataaCode)
print(pataa.address1)
print(pataa.address2)
print(pataa.address3)
print(pataa.zipcode)
print(pataa.cityName)
print(pataa.stateName)
print(pataa.countryName)
print(pataa.latitude)
print(pataa.longitude)
}
}

func didReceivedAddressDetails(_ addressDetails: AddressDetails?) {
if let addressDetails = addressDetails {
print(addressDetails.address1)
print(addressDetails.address2)
print(addressDetails.address3)
print(addressDetails.zipcode)
print(addressDetails.cityName)
print(addressDetails.stateName)
print(addressDetails.countryName)
print(addressDetails.firstName)
print(addressDetails.lastName)
print(addressDetails.latitude)
print(addressDetails.longitude)
}
}
}

To get the user details please use the following code:

func didReceivedAddPataaDetails(_ pataaDetails: PAPataaDetail?, withError error: Error?) {
if let pataaDetails = pataaDetails, let user = pataaDetails.user {
print(user.countryCode)
print(user.firstName)
print(user.lastName)
print(user.mobile)
}
}

If the user didn’t allow location permission & try to create a pataa then you will get all details in this delegate method.

 func didReceivedAddressDetails(_ addressDetails: AddressDetails?) {
if let addressDetails = addressDetails {
print(addressDetails.address1)
print(addressDetails.address2)
print(addressDetails.latitude)
print(addressDetails.longitude)
print(addressDetails.address3)
print(addressDetails.zipcode)
print(addressDetails.cityName)
print(addressDetails.stateName)
print(addressDetails.countryName)
print(addressDetails.firstName)
print(addressDetails.lastName)
print(addressDetails.latitude)
print(addressDetails.longitude)
}
}